<template>
	<!-- 首页广告轮播组件 -->
	<div class="banner-wrapper">
		<u-swiper
			:list="data"
			height="350rpx"
			previousMargin="0"
			nextMargin="0"
			radius="5"
			keyName="poster"
			:showTitle="true"
			indicator
			bgColor="#ffffff"
			indicatorMode="line"
			circular
			@click="onClickBannerItem"
		></u-swiper>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				// 轮播图数据
				data: [],
			}
		},
		mounted() {
			this.findList();
		},
		methods: {
			findList(){
				this.$api.app.banner.findList({adType:1}).then(({data})=>{
					this.data = data;
				});
			},
			/**
			 * 点击广告项
			 */
			onClickBannerItem(index){
				let item = this.data[index];
				let url = item.url;
				console.log("点击了广告项：", item);
				if (url) {
					uni.navigateTo({
						url: '/pages/webview/webview?url=' + url
					})
				}
			},
		}
	}
</script>

<style>
	.banner-wrapper{
		background-color: #FFFFFF;
		padding: 24rpx;
	}
</style>
